<template>
  <div class="person-list">
    <div class="box">
      <ul>
        <li v-for="(item , index ) in dataArr.slice(0,10)" :key="index" @click="skip(item.id)">
          <div class="imgbox">
            <img :src="item.imgurl" />
            <span class="person">2人团</span>
            <p class="title van-multi-ellipsis--l2">{{item.title}}</p>
            <div class="sp">
              拼团价
              <em>{{item.newPrice}}</em>
            </div>
            <div class="mp">
              市场价
              <del>{{item.oldPrice}}</del>
            </div>
          </div>
        </li>
      </ul>
      <ul>
        <li v-for="(item , index ) in dataArr.slice(10,20)" :key="index" @click="skip(item.id)">
          <div class="imgbox">
            <img :src="item.imgurl" />
            <span class="person">2人团</span>
            <p class="title van-multi-ellipsis--l2">抽纸40包竹浆本色不掉屑</p>
            <div class="sp">
              拼团价
              <em>29.9</em>
            </div>
            <div class="mp">
              市场价
              <del>159.80</del>
            </div>
          </div>
        </li>
      </ul>
    </div>
    <div class="chak">
      <span>查看更多</span>
      <van-loading color="#1989fa" />
    </div>
  </div>
</template>

<script>
import { mapActions } from "vuex";
export default {
  name: "groups",
  data() {
    return {
      dataArr: [],
    };
  },
  methods: {
    ...mapActions("home", ["getgroups"]),
    skip(id) {
      this.$router.push({ path: "/detail", query: { id, mode: 0 } });
    },
  },
  async mounted() {
    // 获取拼团数据
    this.dataArr = await this.getgroups();
  },
};
</script>

<style scoped>
.person-list {
  overflow: hidden;
  overflow-x: auto;
  white-space: nowrap;
  height: 5.1rem;
  padding: 10px;
  display: flex;
}

.box {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.person-list::-webkit-scrollbar {
  display: none;
}

ul li {
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
  width: 1.5rem;
  height: 2.5rem;
  margin-right: 10px;
}

.imgbox {
  position: relative;
  height: 55%;
  z-index: -1;
}

.imgbox img {
  width: 100%;
  height: 100%;
}

.person {
  position: absolute;
  bottom: 0;
  left: 0;
  border: 1px solid #ea4141;
  background: rgba(250, 250, 250, 0.86);
  padding: 0 0.05rem;
  border-radius: 0.0933rem;
  line-height: 1.2;
  font-size: 0.2933rem;
  color: #ea4141;
}

.title {
  font-size: 0.19rem;
  line-height: 1;
  overflow: hidden;
  white-space: pre-wrap;
}

.sp {
  line-height: 1.3;
  font-size: 0.2rem;
  color: #ea4141;
}

.sp em {
  margin-left: 0.0667rem;
  font-size: 0.25rem;
  font-weight: 700;
  font-style: normal;
}

.sp em:before {
  font-size: 0.2933rem;
  content: "\00A5";
}

.mp {
  line-height: 1.3;
  font-size: 0.2rem;
  color: #999;
}

.mp del {
  margin-left: 0.0667rem;
}

.mp del:before {
  content: "\00A5";
}

.chak {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
</style>